package sort;

import java.util.ArrayList;
import java.util.List;

public class BubbleSort {

    public static <T extends Comparable> List<T> sort(List<T> nums) {
        List<T> result = new ArrayList<>(nums);
        for (int i = result.size(); i >= 0; i--) {
            for (int j = 1; j < i; j++) {
                if (result.get(j - 1).compareTo(result.get(j)) > 0) {
                    T tmp = result.get(j);
                    result.set(j, result.get(j - 1));
                    result.set(j - 1, tmp);
                }
            }
        }
        return result;


    }
}
